
package com.scs.application.modules.msg.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.scs.application.core.service.BaseServiceImpl;
import com.scs.application.core.utils.StringUtils;
import com.scs.application.core.utils.UserUtils;
import com.scs.application.modules.msg.entity.MscmPushedRecord;
import com.scs.application.modules.msg.mapper.MscmPushedRecordMapper;
import com.scs.application.modules.msg.request.MscmPushedRecordQueryRequest;
import com.scs.application.modules.msg.service.MscmPushedRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* 已推送记录 service 实现
*
*/
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class MscmPushedRecordServiceImpl extends BaseServiceImpl<MscmPushedRecordMapper, MscmPushedRecord> implements MscmPushedRecordService {

    @Override
    public IPage<MscmPushedRecord> page(MscmPushedRecordQueryRequest request) {
            IPage page = this.page(request.getPage(), Wrappers.<MscmPushedRecord>query()
                    .eq("msg_type",request.getMsgType())
                    .like("scene_code", UserUtils.getHospitalId())
                    .like(StringUtils.isNotBlank(request.getTitle()), "title", request.getTitle())
                    .groupBy("title","content")
                    .orderByDesc("gmt_create"));
            return page;
    }
}
